home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / PopupMenuEditor.cpp < prev    next >
Text File  |  1997-02-20  |  5KB  |  166 lines

  1. /*
  2.  *  File:       PopupMenuEditor.cpp
  3.  *  Summary:       A view that knows how to edit a TPopupMenu.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->    12/01/96    JDJ        Created
  12.  */
  13.  
  14. #include "PopupMenuEditor.h"
  15.  
  16. #include <ZTextBox.h>
  17.  
  18.  
  19. // ===================================================================================
  20. //    class CEditPopupMenuCommand
  21. // ===================================================================================
  22.  
  23. //---------------------------------------------------------------
  24. //
  25. // CEditPopupMenuCommand::~CEditPopupMenuCommand
  26. //
  27. //---------------------------------------------------------------
  28. CEditPopupMenuCommand::~CEditPopupMenuCommand()
  29. {
  30. }
  31.  
  32.  
  33. //---------------------------------------------------------------
  34. //
  35. // CEditPopupMenuCommand::CEditPopupMenuCommand
  36. //
  37. //---------------------------------------------------------------
  38. CEditPopupMenuCommand::CEditPopupMenuCommand(TPopupMenu* pane, const SPopupInfo& oldInfo, const SPopupInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
  39. {
  40. }
  41.  
  42.  
  43. //---------------------------------------------------------------
  44. //
  45. // CEditPopupMenuCommand::UpdatePane
  46. //
  47. //---------------------------------------------------------------
  48. void CEditPopupMenuCommand::UpdatePane(const SPopupInfo& inInfo)
  49. {
  50.     // Title is set by a seperate editor so we can't use the 
  51.     // original value.
  52.     SPopupInfo info = inInfo;
  53.     info.stdControlInfo.title = mPane->GetTitle();
  54.     
  55.     mPane->SetInfo(info);
  56. }
  57.  
  58. #pragma mark -
  59.  
  60. // ===================================================================================
  61. //    CPopupMenuEditor
  62. // ===================================================================================
  63.  
  64. static TReanimatorRegister<CPopupMenuEditor> sPopupEditorRegistrar;
  65.  
  66. //---------------------------------------------------------------
  67. //
  68. // CPopupMenuEditor::~CPopupMenuEditor
  69. //
  70. //---------------------------------------------------------------
  71. CPopupMenuEditor::~CPopupMenuEditor()
  72. {
  73. }
  74.  
  75.  
  76. //---------------------------------------------------------------
  77. //
  78. // CPopupMenuEditor::CPopupMenuEditor
  79. //
  80. //---------------------------------------------------------------
  81. CPopupMenuEditor::CPopupMenuEditor(TView* superView) : Inherited(superView)
  82. {
  83. }
  84.  
  85.  
  86. //---------------------------------------------------------------
  87. //
  88. // CPopupMenuEditor::Create                                [static]
  89. //
  90. //---------------------------------------------------------------
  91. MReanimatable* CPopupMenuEditor::Create(MReanimatable* parent)
  92. {
  93.     return new CPopupMenuEditor(dynamic_cast<TView*>(parent));
  94. }
  95.  
  96.  
  97. //---------------------------------------------------------------
  98. //
  99. // CPopupMenuEditor::GetEditorInfo        
  100. //
  101. //---------------------------------------------------------------
  102. SPopupInfo CPopupMenuEditor::GetEditorInfo() const
  103. {
  104.     SPopupInfo info;
  105.     
  106.     TTextBox* textBox = nil;
  107.     TPopupMenu* popup = nil;
  108.         
  109.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Title Width"));
  110.     info.titleWidth = textBox->GetValue();
  111.     
  112.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Menu ID"));
  113.     info.menuID = textBox->GetValue();
  114.     
  115.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Initial Item"));
  116.     info.initialItem = textBox->GetValue();
  117.     
  118.     popup = dynamic_cast<TPopupMenu*>(this->FindSubPane("Justification"));
  119.     if (popup->GetValue() == 1)
  120.         info.titleOptions = popupTitleLeftJust;
  121.     else if (popup->GetValue() == 2)
  122.         info.titleOptions = popupTitleCenterJust;
  123.     else
  124.         info.titleOptions = popupTitleRightJust;
  125.     
  126.     popup = dynamic_cast<TPopupMenu*>(this->FindSubPane("Variation"));
  127.     info.variation = popup->GetValue();
  128.     
  129.     return info;
  130. }
  131.  
  132.  
  133. //---------------------------------------------------------------
  134. //
  135. // CPopupMenuEditor::SetEditorInfo
  136. //
  137. //---------------------------------------------------------------
  138. void CPopupMenuEditor::SetEditorInfo(const SPopupInfo& info)
  139. {
  140.     TTextBox* textBox = nil;
  141.     TPopupMenu* popup = nil;
  142.     
  143.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Title Width"));
  144.     textBox->SetValue(info.titleWidth);
  145.     
  146.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Menu ID"));
  147.     textBox->SetValue(info.menuID);
  148.     
  149.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Initial Item"));
  150.     textBox->SetValue(info.initialItem);
  151.     
  152.     popup = dynamic_cast<TPopupMenu*>(this->FindSubPane("Justification"));
  153.     if (info.titleOptions == popupTitleLeftJust)
  154.         popup->SetValue(1);
  155.     else if (info.titleOptions == popupTitleCenterJust)
  156.         popup->SetValue(2);
  157.     else
  158.         popup->SetValue(3);
  159.  
  160.     popup = dynamic_cast<TPopupMenu*>(this->FindSubPane("Variation"));
  161.     popup->SetValue(info.variation);
  162. }
  163.  
  164.  
  165.  
  166.